package com.electronic.modules.electronicSealSignature.param;

import com.alibaba.fastjson.JSON;
import com.electronic.domain.CebsSdkProperties;
import com.electronic.domain.SignProperties;
import com.electronic.valid.BeanValidator;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @Author: IFCA
 * @Description: 签署配置
 */
@Data
public class CebsSignatureDTO {

    /**
     * 二维码唯一标识
     */
    @NotBlank(message = "二维码唯一标识不能为空")
    private String pid;

    /**
     * 签署配置
     */
    @Valid
    private CebsSdkProperties cebsSdkProperties;

    /**
     * 中招SDk配置
     */
    @Valid
    private SignProperties signProperties;

    public static CebsSignatureDTO validate(String businessData) {
        CebsSignatureDTO dto = JSON.parseObject(businessData, CebsSignatureDTO.class);
        //验证必填项
        BeanValidator.validateReturnException(dto);
        BeanValidator.validateReturnException(dto.getCebsSdkProperties());
        BeanValidator.validateReturnException(dto.getSignProperties());
        return dto;
    }
}
